package com.demo.house.service.impl;

import com.demo.house.dao.AnswerDao;
import com.demo.house.entity.Answer;
import com.demo.house.service.AnswerService;
import com.demo.house.vo.request.RequestAnswerVo;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class AnswerServiceImpl implements AnswerService{

    @Autowired
    private AnswerDao answerDao;


    /**
     * 查询所有评论
     * @return
     */
    @Override
    public List<Answer> queryAll(Answer answer) {
        return answerDao.queryAll(answer);
    }




    /**
     * 用户新增评论
     * @param requestAnswerVo 实例对象
     * @return
     */
    @Override
    public int insert(RequestAnswerVo requestAnswerVo) {
        Answer answer=new Answer();
        answer.setCreateTime(new Date());
        BeanUtils.copyProperties(requestAnswerVo,answer);
        return answerDao.insert(answer);
    }

    @Override
    public List<Answer> list(Integer id) {
        return answerDao.list(id);
    }
}
